﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace storeSMS
{
    public partial class frmConfig : Form
    {
        public frmConfig()
        {
            InitializeComponent();
        }

        private void frmConfig_Load(object sender, EventArgs e)
        {
            string sql = "select top 1 sdays,stimes from configinfo";
            DataSet ds = DbHelperOleDb.Query(sql);
            if (ds.Tables[0].Rows.Count == 1)
            {
                txtsdays.Text = ds.Tables[0].Rows[0][0].ToString();
                txtstimes.Text = ds.Tables[0].Rows[0][1].ToString();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            int sdays=0,stimes=0;
            int.TryParse(txtsdays.Text,out sdays);
            int.TryParse(txtstimes.Text, out stimes);
            if (sdays != 0 && stimes != 0)
            {
                string sql = string.Format("update configinfo set sdays={0},stimes={1}", sdays, stimes);
                if (DbHelperOleDb.ExecuteSql(sql) > 0)
                {
                    myinfo.sdays = sdays;
                    myinfo.stimes = stimes;
                    MessageBox.Show("更新成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("更新失败！");
                }
            }
            else
            {
                MessageBox.Show("天数和时间要是整数！");

            }


        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
